import request from '@/utils/http'
import axios from 'axios'
import { SendEmailCode, SendSmsCode } from '@/api/assistants-type.ts'

const PATH = '/assistants'

export function sendCode(data: any) {
	return request({ url: PATH + '/sendCode', method: 'post', data })
}

export function getCountDown(params: any) {
	return request({ url: PATH + '/getcountdown', method: 'get', params })
}

export function checkCode(data: any) {
	return request({ url: PATH + '/checkCode', method: 'post', data })
}
export function authorizedCheckCode(data: any) {
	return request({ url: PATH + '/authorizedcheckCode', method: 'post', data })
}

export function authorizedSendCode(data: any) {
	return request({ url: PATH + '/authorizedsendcode', method: 'post', data })
}

export function thirdSignIn(data: any) {
	return request({ url: PATH + '/thirdsignin', method: 'post', data })
}

export function getCountries(params: any) {
	return request({ url: PATH + '/getcountries', method: 'get', params })
}

export function getIpInfo() {
	return request({ url: PATH + '/getipinfobyip', method: 'get' })
}

export function getCustomerUrl(params: any) {
	return request({ url: PATH + '/getcustomerurl', method: 'get', params })
}

export function sendStatLink(data: any) {
	return request({ url: 'stat/link', method: 'post', data })
}

export function getVersion() {
	return request({ url: PATH + '/getVersion', method: 'get' })
}

export function getFloater(params: any) {
	return request({ url: PATH + '/getfloater', method: 'get', params })
}

export function getMultiText(params: any) {
	return request({ url: PATH + '/getmultitext', method: 'get', params })
}

export function getMaintenanceData() {
	const url = import.meta.env.VITE_MAINTENANCE_URL + '/get_yw'
	return axios({
		url,
		method: 'get',
		params: {
			referer: location.origin,
			ts: Date.now()
		}
	})
}

export function sendSmsCode(params: SendSmsCode['params']) {
	return request<SendSmsCode['result']>({ url: '/resource/sms/code', method: 'get', params })
}

export function sendEmailCode(params: SendEmailCode['params']) {
	return request<SendEmailCode['result']>({ url: '/resource/email/code', method: 'get', params })
}

export function ossUpload(data: any) {
	return request({ url: `/resource/oss/upload`, method: 'post', data })
}
export function ossDelete(ossIds: any) {
	return request({ url: `/resource/oss/${ossIds}`, method: 'delete' })
}
